<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="<?php echo Yii::app()->baseUrl;?>/assets/bootstrap-3.3.4-dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="<?php echo Yii::app()->baseUrl;?>/assets/uploadify/uploadify.css" />
    <link href="<?php echo Yii::app()->baseUrl;?>/assets/home/css/main.css" rel="stylesheet" /> 
    
    	
    
  </head>
    <body>
  	<div class="container">
	    
	    	<div class="row">
	<div class="col-md-12">
		<p class="text-right top-text">
			<a href="">意见反馈</a><span class="split">|</span><a href="">新手帮助</a>
		</p>
	</div>
</div>
<div class="row">
	<div class="col-md-3">
		<img src="<?php echo Yii::app()->baseUrl;?>/assets/home/images/logo.png" class="img-responsive" />
	</div>
	<div class="col-md-9">
		<nav class="navbar navbar-default top-menu">
		  <div class="container-fluid">
		    <!-- Brand and toggle get grouped for better mobile display -->
		    <div class="navbar-header">
		      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
		        <span class="sr-only">Toggle navigation</span>
		        <span class="icon-bar"></span>
		        <span class="icon-bar"></span>
		        <span class="icon-bar"></span>
		      </button>
		      <span class="glyphicon glyphicon-home" style="font-size:24px;margin:13px 13px 0 0;"></span>
		    </div>
		
		    <!-- Collect the nav links, forms, and other content for toggling -->
		    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
		      <ul class="nav navbar-nav">
		        <li class="active"><a href="#" >看笑话 <span class="sr-only">(current)</span></a></li>
		        <li><a href="#">当评委</a></li>
		        
		      </ul>
		      <form class="navbar-form navbar-left" role="search">
		        <div class="form-group">
		          <input type="text" class="form-control" placeholder="Search">
		        </div>
		        <button type="submit" class="btn btn-default">查笑话</button>
		      </form>
		      <ul class="nav navbar-nav navbar-right">
		      <?php if(Yii::app()->user->isGuest):?>
		      <li><button data-toggle="modal" class="btn btn-info nav-btn" data-target="#toRegister">注册</button></li>
				<li><button data-toggle="modal" class="btn btn-success nav-btn" data-target="#toLogin">登录</button></li>
				<?php else: ?>
				<li><button data-toggle="modal" class="btn btn btn-warning nav-btn" data-target="#toSubmit">发布内容</button></li>
				<li class="dropdown">
		          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">bestone<span class="caret"></span></a>
		          <ul class="dropdown-menu" role="menu">
		          	<li><a href="#toSubmit" data-toggle="modal">发布内容</a></li>
		            <li class="divider"></li>
		            <li><a href="#">我的主页</a></li>
		            <li class="divider"></li>
		            <li><a href="#">信息设置</a></li>
		            <li class="divider"></li>	
		            <li><a href="#">退出登录</a></li>      
		          </ul>
		        </li>		      
		        <?php endif;?>
		        </ul>
		    </div>
		  </div>
		</nav>
	</div>
</div>
  <?php echo $content;?>
  
  <!-- 用户注册 -->
<div class="modal fade" id="toRegister" tabindex="-1" role="dialog" aria-labelledby="toRegister" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">用户注册</h4>
      </div>
      <div class="modal-body">
        <?php echo CHtml::beginForm($this->createUrl('user/register'), 'post',array('class'=>'form-horizontal'));?>
          <div class="form-group">
          	<label class="control-label col-sm-2">用户名</label>
          	<div class="col-sm-10">
            <?php 
            	echo CHtml::textField('username', '', array('class'=>'form-control', 'placeholder'=>'请输入用户名'));
            ?>
            </div>
          </div>
          <div class="form-group">
          	<label class="control-label col-sm-2">密码</label>
          	<div class="col-sm-10">
            <?php 
            	echo CHtml::passwordField('password', '', array('class'=>'form-control','placeholder'=>'密码'));
            ?>
            </div>
          </div>
          <div class="form-group">
          	<label class="control-label col-sm-2">Email</label>
          	<div class="col-sm-10">
          	<?php 
          		echo CHtml::textField('email','',array('placeholder'=>'邮箱','class'=>'form-control'));
          	?>
          	</div>
          </div>
          <div class="form-group row">
          	<label class="control-label col-sm-2">验证码</label>
          	<div class="col-sm-3">
          		<?php 
          			echo CHtml::textField('captcha','',array('placeholder'=>'邮箱','class'=>'form-control'));
          		?>
          	</div>
          	<div class="col-sm-3">
          		<?php
					$this->widget('CCaptcha',array('showRefreshButton'=>false,'clickableImage'=>true,'imageOptions'=>array('alt'=>'点击换图','title'=>'点击换图','style'=>'cursor:pointer')));
				?>
          	</div>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <?php echo CHtml::submitButton('注册',array('class'=>'btn btn-default', 'id'=>'doRegister'));?>
      </div>
      <?php echo CHtml::endForm();?>
    </div>
  </div>
</div>

<!-- 用户登录 -->
<div class="modal fade" id="toLogin" tabindex="-1" role="dialog" aria-labelledby="toLogin" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">用户登录</h4>
      </div>
      <div class="modal-body">
        <form>
          <div class="form-group">
            <input type="text" name="username" class="form-control" id="username" placeholder="邮箱，格式如：admin@dakuaile.cn">
          </div>
          <div class="form-group">
            <input class="form-control" type="password" name="password" id="password" placeholder="密码" />
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-loading-text="Loading..." id="login">登录</button>
      </div>
    </div>
  </div>
</div>

<!-- 发布内容 -->
<div class="modal fade" id="toSubmit" tabindex="-1" role="dialog" aria-labelledby="toSubmit" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">发布内容</h4>
      </div>
      <div class="modal-body">
        <form>
          <div class="form-group">
            <input type="text" name="username" class="form-control" id="username" placeholder="给发布的内容取个逗B的标题">
          </div>
          <div class="form-group">
            <textarea class="form-control" name="content" id="content" placeholder="内容，不超过500个汉子" rows="10" ></textarea>
          </div>
          <div class="form-group">
          	<input type="text" name="tags" class="form-control" placeholder="内容标签，多个标签请用空格区分" />
          </div>
          	<div class="form-group">
          		<input type="file" name="pic" id="pic" />
          		<span>(如果发布内容需要配图，请上传，否则请留空)</span>
          	</div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-loading-text="Loading..." id="submit">发布</button>
      </div>
    </div>
  </div>
</div>
		
	</div>

<div class="footer container-fluid">
	<div class="row">
		<div class="col-md-12 text-center footer-links">
			<ul class="list-inline">
				<li><a href="">关于我们</a></li>
				<li><a href="">关于我们</a></li>
				<li><a href="">关于我们</a></li>
				<li><a href="">关于我们</a></li>
				<li><a href="">关于我们</a></li>
			</ul>
			<p class="text-center">
				京ICP证120017号
			</p>
		</div>
	</div>
</div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <?php Yii::app ()->clientScript->registerCoreScript ( 'jquery' );?>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="<?php echo Yii::app()->baseUrl;?>/assets/bootstrap-3.3.4-dist/js/bootstrap.min.js"></script>
    <script src="<?php echo Yii::app()->baseUrl;?>/assets/uploadify/jquery.uploadify.min.js"></script>
    <script>
    	$(function(){
    		$('#pic').uploadify({
        		"swf" : '<?php echo Yii::app()->baseUrl;?>/assets/uploadify/uploadify.swf',
                "fileObjName": "pic",
                "buttonText": "上传图片",
                //'buttonClass': 'btn btn-info',
                "uploader": "/file/uploadpicture/session_id/09qtjp01eq6ot7tfko7m02cfl1.html",
                'removeTimeout': 1,
                'fileTypeExts': '*.jpg; *.png; *.gif;',
                "onUploadSuccess": function(file, data, response){
                	
                },
                'onFallback': function() {
                    alert('未检测到兼容版本的Flash.');
                }
        	});

        	//登录
    		$('#doRegister').click(function(){
        		alert(111);
    			$.ajax({
    				method : 'post',
    				dataType : 'json',
    				url : '<?php echo $this->createUrl("user/register");?>',
    				data : {
    					'username' : $('#username').attr('value'),
    					'password' : $('#password').attr('value'),
    					'email' : $('#email').attr('value')
    					}
    			});
    			return false;
    		});
    	});
    </script>
  </body>
</html>